package com.joinval.common.utils;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author shen shuai
 * @create 2024-09-27 下午 3:57
 */

// @Component
public class SignatureInterceptor implements HandlerInterceptor {

    // @Override
    // public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
    //     System.out.println("=========== SignatureInterceptor preHandle ==========");
    //     String sign = request.getParameter("sign");
    //     String timestamp = request.getParameter("timestamp");
    //     if (StringUtils.isNotBlank(sign) && StringUtils.isNotBlank(timestamp)) {
    //         String signature = SignatureUtil.getSignature(timestamp);
    //         if (StringUtils.isNotBlank(signature) && signature.equals(sign) && System.currentTimeMillis() - Long.parseLong(timestamp) < 50 * 1000) {
    //             return true;
    //         } else {
    //             request.getRequestDispatcher("/joinval/interfaceCenter/page").forward(request, response);
    //             return false;
    //         }
    //     } else {
    //         throw new RuntimeException("签名错误");
    //         // return false;
    //     }
    // }
}

